<template>
  <div></div>
</template>

<script>
export default {
  data() {
    return {};
  },
  created() {},
  methods: {
    ...mapActions([
      "handleLogin",
      "getUserInfo",
      "handlegoLogin",
      "wxAuthlogin",
    ]),
    // 扫码登录
    handleCodeSubmit(data) {
      if (data) {
        this.handlegoLogin({
          authCode: data.authCode,
        })
          .then((resLogin) => {
            if (resLogin.code === 20000) {
              localStorage.setItem(
                "ifaccountyesnoQYWX",
                resLogin.data.thirdType
              );
              this.$store.commit("print/setPrint", {
                ifaccountyesnoQYWX: localStorage.getItem("ifaccountyesnoQYWX"),
              });
              this.getUserInfo(resLogin)
                .then((res) => {
                  // 获取角色路由
                  this.APIS.getMenuList()
                    .then((res) => {
                      // service.routerRes(res.data);
                      this.$router.replace({
                        name: this.$config.homeName,
                      });
                      localStorage.setItem("menus", this.$config.homeName);
                      this.loginLoading = false;
                    })
                    .catch((err) => {
                      this.loginLoading = false;
                      removeToken();
                    });
                })
                .catch(() => {
                  this.loginLoading = false;
                });
            } else {
              this.loginLoading = false;
            }
          })
          .catch(() => {
            this.loginLoading = false;
            // this.$router.push({
            //   name: this.$config.homeName
            // })
          });
      }
    },
  },
};
</script>

<style lang="less">
</style>
